<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<style type="text/css">
INPUT {font-size:20px};
TEXTAREA{font-size:20px};
Button {font-size :20px};
</style>
<meta name="viewport" content="width=320px, user-scalable=no, initial-scale=1, maximum-scale=1" charset="utf-8"> </meta>
<title>参数设置</title>
</head>
<body>
<form  action="set" method="post" enctype="application/x-www-form-urlencoded" >
  <table width="0" border="0">
    <td>路由器（ssid）:</td>
    <td><input name="AP_ssid" type="text" /></td>
  </tr>
  <tr>
    <td>路由器密码(password):</td>
    <td><input name="AP_pwd" type="text" /></td>
  </tr>
  <tr>
    <td>--------------</td>
  </tr>
  <tr>
    <td>目标端口:</td>
    <td><input name="Server_port" type="number" /></td>
  </tr>
  <tr>
    <td>目标IP地址:</td>
    <td><input name="Server_IP" type="text" /></td>
  </tr>
</table>
<div id="message"></div>
<input name="submitOK" type="submit" value="确定" />

</form>
 <iframe  name="stop" style="display:none;"></iframe>
<form action="ask" method="get" enctype="application/x-www-form-urlencoded">
<input name="ask" type="submit" value="查询配置" />
</form>
<form id="form1" enctype="multipart/form-data" method="post" action="Upload.aspx">
    <div class="row">
        <label for="fileToUpload">Select a File to Upload</label><br>
        <input type="file" name="fileToUpload" id="fileToUpload" onchange="fileSelected();">
    </div>
    <div id="fileName"></div>
    <div id="fileSize"></div>
    <div id="fileType"></div>
    <div class="row">
        <input type="button" onclick="uploadFile()" value="Upload">
    </div>
    <div id="progressNumber"></div>
</form>
<script>
function fileSelected() {
    var file = document.getElementById('fileToUpload').files[0];
    if (file) {
        var fileSize = 0;
        if (file.size > 1024 * 1024)
            fileSize = (Math.round(file.size * 100 / (1024 * 1024)) / 100).toString() + 'MB';
        else
            fileSize = (Math.round(file.size * 100 / 1024) / 100).toString() + 'KB';
        document.getElementById('fileName').innerHTML = 'Name: ' + file.name;
        document.getElementById('fileSize').innerHTML = 'Size: ' + fileSize;
        document.getElementById('fileType').innerHTML = 'Type: ' + file.type;
    }
}

function uploadFile() {
    var fd = new FormData();
    fd.append("fileToUpload", document.getElementById('fileToUpload').files[0]);
    var xhr = new XMLHttpRequest();
    xhr.upload.addEventListener("progress", uploadProgress, false);
    xhr.addEventListener("load", uploadComplete, false);
    xhr.addEventListener("error", uploadFailed, false);
    xhr.addEventListener("abort", uploadCanceled, false);
    xhr.open("POST", "/main.html"); //修改成自己的接口
    xhr.send(fd);
}

function uploadProgress(evt) {
    if (evt.lengthComputable) {
        var percentComplete = Math.round(evt.loaded * 100 / evt.total);
        document.getElementById('progressNumber').innerHTML = percentComplete.toString() + '%';
    } else {
        document.getElementById('progressNumber').innerHTML = 'unable to compute';
    }
}

function uploadComplete(evt) {
    /* 服务器端返回响应时候触发event事件*/
    alert(evt.target.responseText);
}
function AJAXSubmit(ele)
{
	var xhr = new XMLHttpRequest();
	var fd = new FormData(ele);
	xhr.onreadystatechange=function()
	{
		if(xhr.readyState==4 && xhr.status==200 )
		{
			document.getElementById('message').innerHTML=xhr.responseText;
		}
	}
    xhr.open("POST", ele.action); //修改成自己的接口
	xhr.setRequestHeader('Content-Type','application/x-www-form-urlencode');   
	xhr.send(fd);
	return false;
}
function uploadFailed(evt) {
    alert("There was an error attempting to upload the file.");
}

function uploadCanceled(evt) {
    alert("The upload has been canceled by the user or the browser dropped the connection.");
}


</script>
</body>
</html>